﻿<%@ Page Title="Frontdesk - Form Editor" Language="C#" MasterPageFile="~/Views/Shared/Frontdesk.Master"
    Inherits="System.Web.Mvc.ViewPage<Sendz.Domain.Form>" %>

<asp:Content ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ContentPlaceHolderID="MainContent" runat="server">
    <h2>
        Form Editor</h2>
    <% using (Ajax.BeginForm(new AjaxOptions { Url = "/Form/Edit", OnBegin = "onBegin", UpdateTargetId = "wrapper", InsertionMode = InsertionMode.Replace }))
       { %>
    <div class="form-field">
        <div class="form-field-label">
            <%: Html.LabelFor(f => f.Name)%></div>
        <div class="form-field-error">
            <%: Html.ValidationMessageFor(f => f.Name)%></div>
        <div class="form-field-input">
            <%: Html.TextBoxFor(f => f.Name, new { @class = "frontdesk" })%></div>
    </div>
    <div class="form-field">
        <div class="form-field-label">
            <%: Html.LabelFor(f => f.IsRedirectOnComplete)%>
        </div>
        <div class="form-field-input">
            <%: Html.DropDownListFor(f => f.IsRedirectOnComplete, new SelectList((IEnumerable)ViewData["TrueFalseList"], "Value", "Text", Model.IsRedirectOnComplete), new { @class = "frontdesk" })%>
        </div>
    </div>
    <div class="form-field">
        <div class="form-field-label">
            <%: Html.LabelFor(f => f.RedirectURL)%>
        </div>
        <div class="form-field-error">
            <%: Html.ValidationMessageFor(f => f.RedirectURL)%></div>
        <div class="form-field-input">
            <div class="inline-help-group">
                <%: Html.TextBoxFor(f => f.RedirectURL, new { @class = "frontdesk" })%><img src="<%= Url.Content("~/Content/Frontdesk/questionmark.png") %>"
                    class="inline-help" title="A redirect URL is something like http://www.mysite.com/thanks ... this way, when you opt to use a redirect, the Frontdesk system knows where to re-route the people who fill out your form (to a thank-you page, your website, etc.)!"
                    alt="Help icon" /></div>
        </div>
    </div>
    <div class="form-field">
        <div class="form-field-label">
            <%: Html.LabelFor(f => f.CompletionMessage)%>
        </div>
        <div class="form-field-error">
            <%: Html.ValidationMessageFor(f => f.CompletionMessage)%>
        </div>
        <%: Html.TextAreaFor(f => f.CompletionMessage, new { rows = "7", cols = "65" })%>
        <div class="inline-help-group">
            <p class="caption clear">
                Turn the WYSIWYG Editor [<a href="javascript:;" onclick="addEditor();" title="Turn the visual HTML editor on in your browser (works in most modern browsers)">ON</a>]
                [<a href="javascript:;" onclick="removeEditor();" title="Turn the visual HTML editor off">OFF</a>]<img
                    src="<%= Url.Content("~/Content/Frontdesk/questionmark.png") %>" class="inline-help"
                    title="WYSIWYG help means 'What You See Is What You Get'. If your browser can support this type of editor, when you turn it on you should see some basic Word-like formatting controls including bullets, links, etc."
                    alt="Help icon" /></p>
        </div>
    </div>
    <% if (ViewData["AutoResponders"] != null)
       { %>
    <div class="form-field">
        <div class="form-field-label">
            <%: Html.LabelFor(f => f.AutoResponderKey)%>
        </div>
        <div class="form-field">
            <div class="inline-help-group">
                <%: Html.DropDownListFor(f => f.AutoResponderKey, new SelectList((IEnumerable)ViewData["AutoResponders"], "Value", "Text", Model.IsRedirectOnComplete), new { @class = "frontdesk" })%><img
                    src="<%= Url.Content("~/Content/Frontdesk/questionmark.png") %>" class="inline-help"
                    title="Pairing your form with an autoresponder is how people who fill out your form can receive a message from you. Once you pair the form and autoresponder, the next time you visit the autoresponder 'edit' screen, you can use form fields (the values entered by the user) as a part of the response... which lets it feel customized."
                    alt="Help icon" /></div>
        </div>
    </div>
    <% if (TempData["AutoResponderMessage"] != null)
       { %>
    <p class="caption justify critical fullborder">
        <%: TempData["AutoResponderMessage"]%></p>
    <% } %>
    <% } %>
    <div class="form-field">
        <div class="form-field-label">
            <%: Html.LabelFor(f => f.AlertOnComplete)%>
        </div>
        <div class="form-field-input">
            <div class="inline-help-group">
                <%: Html.DropDownListFor(f => f.AlertOnComplete, new SelectList((IEnumerable)ViewData["TrueFalseList"], "Value", "Text", Model.AlertOnComplete), new { @class = "frontdesk" })%><img
                    src="<%= Url.Content("~/Content/Frontdesk/questionmark.png") %>" class="inline-help"
                    title="Alerts are pretty simple really. When enabled, an email will be sent to the account owner anytime a form is filled out, complete with the details included in the response. Swanky, huh?"
                    alt="Help icon" /></div>
        </div>
    </div>
    <div class="form-actions">
        <%: Html.Hidden("IsNewform", ViewData["IsNewForm"])%>
        <%: Html.Hidden("SaveClose", false) %>
        <%: Html.Hidden("UserKey", Model.UserKey)%>
        <%: Html.Hidden("FormKey", Model.FormKey)%>
        <input type="submit" value="Save & Continue" class="button" title="Save this form and go to the form field editor"
            onclick="preSave(false);" />
        <% if (!(bool)ViewData["IsNewForm"])
           { %>
        <input type="submit" value="Save & Close" class="button" title="Save this form and return to the dashboard"
            onclick="preSave(true);" />
        <% } %>
        <input type="button" class="button" value="Cancel" title="Don't save this form, but return to the dashboard instead"
            onclick="window.location = '/Form/List';" />
    </div>
    <% } %>
</asp:Content>
<asp:Content ContentPlaceHolderID="Sidebar" runat="server">
    <% Html.RenderPartial("videohelp"); %>
</asp:Content>
<asp:Content ContentPlaceHolderID="footer" runat="server">
    <script type="text/javascript" src="http://js.nicedit.com/nicEdit-latest.js"></script>
    <script type="text/javascript">
        //<![CDATA[
        var editorArea;

        function addEditor() {
            editorArea = new nicEditor({ buttonList: ['bold', 'italic', 'underline', 'strikeThrough', 'subscript', 'superscript', 'link', 'unlink', 'ul', 'ol'] }).panelInstance('CompletionMessage'); // { fullPanel: true }
        }
        function removeEditor() {
            editorArea.removeInstance('CompletionMessage');
        }
        //]]>
        function preSave(close) {
            if (nicEditors.findEditor('CompletionMessage') != null) {
                $('#CompletionMessage').val(nicEditors.findEditor('CompletionMessage').getContent()); // used escape() previously
            }
            if (close) {
                document.getElementById('SaveClose').value = 'true';
            }
        }
    </script>
</asp:Content>
